class TabItem extends egret.Sprite{


    public isSelected:boolean = false;
    private config:any = {};

    constructor(config:any){
        super();
        this.config = config;
        this.initView();
        this.touchEnabled = true;
    }

    private bg:egret.Bitmap;
    private text:egret.TextField;


    private initView():void{
        let config = this.config;
        let bg:egret.Bitmap = utils.createBitmapByName(config.default_bg||'tab2');
        this.addChild(bg);
        this.bg = bg;
        let txt:egret.TextField = utils.createTextField({
            width:bg.width,
            height:bg.height,
            text:config.content,
            textColor:config.default_color||0xF5C388,
            stroke:config.stroke||2,
            strokeColor:config.stroke_color||0x7F4611,
            size:config.size||30
        });
        this.addChild(txt);
        this.text = txt;
    }


    public changeSelected(selected:boolean):void{
        if(this.isSelected == selected){
            return;
        }
        this.isSelected = selected;
        if(selected){
            this.bg.texture = RES.getRes(this.config.selecte_bg || 'tab3');
            this.text.textColor = this.config.selecte_color||0x7F4611;
            this.text.strokeColor = this.config.selecte_stroke_color||0xF5C388;
        }else{
            this.bg.texture = RES.getRes(this.config.default_bg || 'tab2');
            this.text.textColor = this.config.default_color||0xF5C388;
            this.text.strokeColor = this.config.stroke_color||0x7F4611;
        }

    }


}